package com.fr.cell.comp;

import java.awt.event.ActionEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.JSpinner;

public class SpinnerWheelSupport
{
  public static final String CLIENT_PROPERTY_MOUSE_WHEEL_LISTENER = "mouseWheelListener";
  protected static final String ACTION_NAME_INCREMENT = "increment";
  protected static final String ACTION_NAME_DECREMENT = "decrement";

  public static void installMouseWheelSupport(JSpinner paramJSpinner)
  {
    1 local1 = new MouseWheelListener(paramJSpinner)
    {
      private final JSpinner val$spinner;

      public void mouseWheelMoved(MouseWheelEvent paramMouseWheelEvent)
      {
        Action localAction;
        int i = paramMouseWheelEvent.getWheelRotation();
        if (i > 0)
        {
          localAction = this.val$spinner.getActionMap().get("increment");
          if (localAction != null)
            localAction.actionPerformed(new ActionEvent(paramMouseWheelEvent.getSource(), 0, "increment"));
        }
        else if (i < 0)
        {
          localAction = this.val$spinner.getActionMap().get("decrement");
          if (localAction != null)
            localAction.actionPerformed(new ActionEvent(paramMouseWheelEvent.getSource(), 0, "decrement"));
        }
      }
    };
    paramJSpinner.addMouseWheelListener(local1);
    paramJSpinner.putClientProperty("mouseWheelListener", local1);
  }

  public static void uninstallMouseWheelSupport(JSpinner paramJSpinner)
  {
    MouseWheelListener localMouseWheelListener = (MouseWheelListener)paramJSpinner.getClientProperty("mouseWheelListener");
    if (localMouseWheelListener != null)
      paramJSpinner.removeMouseWheelListener(localMouseWheelListener);
  }
}